<?php


namespace app\api\controller;


use app\common\controller\Api;

class Shop extends Api
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';



    /**
     * 店铺列表
     * @ApiMethod GET
     */
    public function getList(\app\common\model\ShopModel $ShopModel)
    {
        $return = $ShopModel->getList();
        $this->errorReturn($return['code'],$return['data'],$return['msg']);
    }



    /**
     * 商家-自提商品核销
     * @ApiMethod POST
     * @ApiParams int $user_id
     * @ApiParams string $claim_code 取件码
     */
    public function zitiGoodsVerification(\app\common\model\ShopModel $ShopModel, \app\api\validate\ShopValidate $ShopValidate)
    {
        $params = $this->request->post();
        if(!$ShopValidate->check($params,[],'zitiGoodsVerification')){
            $this->errorReturn(40001,$params,$ShopValidate->getError());
        }
        $user_id = $this->auth->id;
        $return = $ShopModel->zitiGoodsVerification($params, $user_id);
        $this->errorReturn($return['code'],$return['data'],$return['msg']);
    }



    /**
     * 商家-兑换券核销
     * @ApiMethod POST
     * @ApiParams int $user_id
     * @ApiParams string $claim_code 取件码
     */
    public function couponExchangeVerification(\app\common\model\ShopModel $ShopModel, \app\api\validate\ShopValidate $ShopValidate)
    {
        $params = $this->request->post();
        if(!$ShopValidate->check($params,[],'couponExchangeVerification')){
            $this->errorReturn(40001,$params,$ShopValidate->getError());
        }
        $user_id = $this->auth->id;
        $return = $ShopModel->couponExchangeVerification($params, $user_id);
        $this->errorReturn($return['code'],$return['data'],$return['msg']);
    }


}